<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  function myFilter(arr, fn) {
    var newarr = [];
    for (i = 0; i < arr.length; i++) {
      var item = arr[i];
      var index = i;
      var array = arr;
      var result = fn(item, index, array)
      // fn(item, index, array) && newarr.push(item, index, array);
      if (result) {
        newarr.push(item);
        // return true;
      }
    }
    return newarr;

  }

  var Arr = [2, 8, 4, 6, 5, 7, 9, 3, 1];
  var newarr = myFilter(Arr, function (item, index, array) {
    // console.log(item, index, array);
    return item > 7;
  })
  console.log(newarr);
</script>

</html>